package algorithm;

import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        String str = reader.nextLine();
        String[] list = str.split(" ");
        int[] intlist = new int[list.length];
        for (int i = 0; i < list.length; i++) {
            intlist[i] = Integer.parseInt(list[i]);
        }
        int ans = 0;
        for (int k = 0; k < intlist.length; k++) {
            for (int i = 0; i < intlist.length; i++) {
                if (i < intlist.length - 1 && intlist[i] > intlist[i + 1]) {
                    int temp = intlist[i];
                    int j = intlist.length - 1;
                    while (intlist[i] < intlist[j]) {
                        j--;
                    }
                    for (int z = i; z < j; z++) {
                        intlist[z] = intlist[z + 1];
                    }
                    intlist[j] = temp;
                    ans++;
                }
            }

            System.out.println(ans);

        }
    }
}
